package cn.bs.seckill.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQFanoutConfig {

    private static final String QUEUE_1="我是广播队列一的消息";
    private static final String QUEUE_2="我是广播队列二的消息";
    private static final String EXCHANGE="我是广播模式的交换机";

    //新建队列一
    @Bean
    public Queue queue1(){
        return new Queue(QUEUE_1);
    }

    //新建队列二
    @Bean
    public Queue queue2(){
        return new Queue(QUEUE_2);
    }

    //新建广播模式交换机
    @Bean
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange(EXCHANGE);
    }

    //把队列和交换机绑定
    @Bean
    public Binding binding1(){
        return BindingBuilder.bind(queue1()).to(fanoutExchange());
    }
    @Bean
    public Binding binding2(){
        return BindingBuilder.bind(queue2()).to(fanoutExchange());
    }

}
